<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>偶像练习生</title>
</head>
<style>
    * {
        box-sizing: border-box;
    }
    .box{
        width:120px;
        height:20px;
        background: red;
    }
    .progress-1 {
        background:
                linear-gradient(#000 0 50%, #000 50% 0) 0/0% no-repeat
                #ddd;
        animation:p1 2s  ease-in-out;
        animation-fill-mode:forwards;
    }
    @keyframes p1 {
        100% {background-size: 100%;}
    }
</style>
<body>
    <div id="test"class="box"></div>
    <button onclick="add()">add</button>
    <button onclick="remove()">remove</button>
</body>
<script>
    var div = document.getElementById("test");
    function add(){
        div.classList.add('progress-1');
    }
    function remove(){
        div.classList.remove('progress-1');
    }
    div.addEventListener("webkitAnimationEnd", function(){ //动画结束时事件
        //this.className = this.className.replace('change', ' ');
        alert('结束!');
        console.log(2);
    }, false);
</script>
</html>